<!doctype html>
<html class="no-js">
<head>
    <link rel="stylesheet" href="${rootPath!''}/assets/css/amazeui.min.css"/>
    <link rel="stylesheet" href="${rootPath!''}/assets/css/admin.css">
</head>
<body style="width: 100%;height: 100%;">
<!-- content start -->
<div class="admin-content">

    <!-- 导航 开始 -->
    <div class="am-cf am-padding">
        <div class="am-fl am-cf"><strong class="am-text-primary am-text-lg">健身房</strong> / <small></small></div>
    </div>
    <!-- 导航 结束 -->

    <!-- 功能键和导航 开始 -->
    <div class="am-g">

        <!-- 左边，功能键开始 -->
        <div class="am-u-sm-12 am-u-md-6">
            <div class="am-btn-toolbar">
                <div class="am-btn-group am-btn-group-xs">
                    <%if(so.hasPermission("GymController.addCount")){%>
                        <button onclick="openAddCountModal();" type="button" class="am-btn am-btn-success"><span class="am-icon-plus"></span> 新增团购</button>
                    <%}%>
                </div>
            </div>
        </div>
    </div>
    <!-- 功能键和导航 结束 -->

    <!-- 内容 开始 -->
    <div class="am-g">
        <div class="am-u-sm-12">
            <ul class="am-avg-sm-2 am-avg-md-4 am-avg-lg-6 am-margin gallery-list">
                <%
                for(data in list){
                %>
                <li>
                    <div onclick="toPage(${data.gymId})" style="border:1px solid #0000ff;width: 250px;height: 200px;text-align: center;line-height: 200px;" >
                        ${data.gymName}(${data.counts}/${data.yuyue}/${data.totals})
                    </div>
                </li>
                <%}%>
            </ul>
        </div>
    </div>
</div>

<div class="am-modal am-modal-alert" tabindex="-2" id="addCount-alert">
    <div class="am-modal-dialog">
        <div class="am-modal-hd">新增团购</div>
        <div class="am-modal-bd">
            <div class="am-modal-bd">
                <div class="am-g">
                    <div class="am-u-sm-6">
                        <select name="gymId">
                            <%for(gym in gyms){%>
                            <option value="${gym.gymId}" >${gym.gymName!}</option>
                            <%}%>
                        </select>
                    </div>
                    <div class="am-u-sm-6"><input type="number" min="1" max="999" name="count" value="1"></div>
                </div>
            </div>
        </div>
        <div class="am-modal-footer">
            <span class="am-modal-btn" onclick="addCount();" style="background-color: blue;color: white">确认</span>
            <span class="am-modal-btn" data-am-modal-cancel>取消</span>
        </div>
    </div>
</div>

<button style="display: none" id="uselogBtn"
        type="button"
        class="am-btn am-btn-primary"
        data-am-modal="{target: '#uselog'}">

</button>

<div class="am-modal am-modal-alert" tabindex="-1" id="uselog">
    <div class="am-modal-dialog">
        <div class="am-modal-hd" id="uselogcontent"></div>
        <div class="am-modal-footer">
            <span class="am-modal-btn" id="useConfig" onclick="toPage1()">确定</span>
        </div>
    </div>
</div>

<!-- content end -->
<!--[if lt IE 9]>
<script src="http://libs.baidu.com/jquery/1.11.1/jquery.min.js"></script>
<script src="http://cdn.staticfile.org/modernizr/2.8.3/modernizr.js"></script>
<script src="${rootPath}/assets/js/polyfill/rem.min.js"></script>
<script src="${rootPath}/assets/js/polyfill/respond.min.js"></script>
<script src="${rootPath}/assets/js/amazeui.legacy.js"></script>
<![endif]-->

<!--[if (gte IE 9)|!(IE)]><!-->
<script src="${rootPath}/assets/js/jquery.min.js"></script>
<script src="${rootPath}/assets/js/amazeui.min.js"></script>
<!--<![endif]-->
<script src="${rootPath}/assets/js/app.js"></script>
<script type="text/javascript">
    function toPage1(){
        location.href = "${rootPath}/gym"
    }
    function toPage(gymId){
        location.href = "${rootPath}/gym/list?gymId="+gymId;
    }
    function openAddCountModal(){
        $("#addCount-alert").modal("open");
    }
    function addCount(){
        if( $( "input[name='count']" ).val() == '' || $( "input[name='count']" ).val() == 0 ) {
            window.top.tips( "请填写次数！" );
            $("input[name='count']").focus() ;
            return ;
        }
        var count = $( "input[name='count']" ).val();
        var gymId = $("select[name='gymId']").val();
        $.post( "${rootPath}/gym/addCount", {"gymId":gymId,"count":count} , function ( data ) {
            debugger
            if ( data.status == 1 ) {
                $('#addCount-alert').modal('close');
                $("#content").attr("src","${rootPath}/gym") ;
            }
            $( "input[name='count']" ).val(1);
            $('#uselogcontent').text( data.msg);
            $('#uselogBtn').click();
        }, "json" );
    }
</script>
</body>
</html>